package design.pattern.Lu12StrategyPattern;

/**
 * @program JavaBase
 * @description: 策略枚举
 * @author: zhanglu
 * @create: 2020-04-09 13:51:00
 */
public class StrategyPattern01 {

    public static void main(String[] args) {
        System.out.println(Calculator.ADD.exec(2, 5));
    }

}

enum Calculator{

    ADD("+"){
        @Override
        public int exec(int a, int b) {
            return a + b;
        }
    },

    SUB("-"){
        @Override
        public int exec(int a, int b) {
            return a - b;
        }
    }

    ;

    private String value;

    Calculator(String value) {
        this.value = value;
    }

    public abstract int exec(int a, int b);

}

